<?php
namespace app\admin\model;

use think\model\concern\SoftDelete;
use think\model\relation\HasMany;

class Role extends AdminModel
{
    use SoftDelete;

    protected $autoWriteTimestamp = true;

    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';
    protected $defaultSoftDelete = null;
	protected $name = 'system_role';

	protected $schema = [
	    'id' => 'int',
        'name' => 'string',
        'description' => 'string',
        'status' => 'int',
        'createtime' => 'int',
        'updatetime' => 'int',
        'deletetime' => 'int',
    ];
	
	/**
	 * 新增、更新需要操作的字段
	 */
	protected $submitField = [
        'status' => 'int'
	];

    public function permession(){
        return $this->hasMany(Permession::class,'role_id');
    }

    protected function setAttrStatus($data){
        if(isset($data['status'])) return 1;
        return 0;
    }


}

